Skip to content

Rust implementation of "rescript format" #7603

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 17, 2025
Merged

Conversation

cknitt
Copy link
Member

@cknitt cknitt commented Jul 5, 2025

Do not forward the rescript format command to the legacy JS cli anymore, instead implement the functionality natively in Rust.

Copy link

pkg-pr-new bot commented Jul 5, 2025

Open in StackBlitz

rescript

npm i https://pkg.pr.new/rescript-lang/rescript@7603

@rescript/darwin-arm64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/darwin-arm64@7603

@rescript/darwin-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/darwin-x64@7603

@rescript/linux-arm64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/linux-arm64@7603

@rescript/linux-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/linux-x64@7603

@rescript/win32-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/win32-x64@7603

commit: 8f2970b

Copy link
Collaborator

@nojaf nojaf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rewatch format --help

thread 'main' panicked at /Users/nojaf/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/clap_builder-4.5.31/src/builder/debug_asserts.rs:570:9:
Positional argument `[FOLDER]` *must* have `required(true)` or `last(true)` set because a prior positional argument (`[FILES]...`) has `num_args(1..)`
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

There is something weird in the setup here, the help crashes.
Might be related to the files: Vec<string>, but I'm not sure.

@cknitt cknitt force-pushed the rescript-format-rust branch 8 times, most recently from 0e9bb0c to e276090 Compare July 16, 2025 19:36
@cknitt cknitt force-pushed the rescript-format-rust branch from e276090 to 1268640 Compare July 16, 2025 19:37
@cknitt cknitt marked this pull request as ready for review July 16, 2025 20:12
@cknitt cknitt requested review from nojaf, jfrolich and Bushuo July 16, 2025 20:13
Copy link
Collaborator

@nojaf nojaf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This worked well with --all in my monorepo setup! Great job!

One small thing to follow up on is that rescript format --check without any input doesn’t provide any output. Perhaps we should log a message indicating that no input was found. I encountered this issue when I forgot to include the --all argument, which was a bit confusing at first.

@zth
Copy link
Collaborator

zth commented Jul 17, 2025

Note for the future - we could add an option to also format docstrings, using the new tools format command.

@cknitt
Copy link
Member Author

cknitt commented Jul 17, 2025

@nojaf Thanks a lot for testing! Could you retry? I now specified that either --all, --stdin, or files must be present.

@nojaf
Copy link
Collaborator

nojaf commented Jul 17, 2025

Thanks! That worked for me:

image

@cknitt cknitt merged commit caf4154 into master Jul 17, 2025
27 checks passed
@cknitt cknitt deleted the rescript-format-rust branch July 17, 2025 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants